package zuoye;

public class DvdMgr {
	String name;
	Dvd[] DVD = new Dvd[33];

	public boolean add(Dvd v) {
		for (int i = 0; i < DVD.length; i++) {
			if (DVD[i] == null) {
				DVD[i] = v;
				return true;
			}
		}
		return false;
	}

	public void showDVDsInfo() {
		for (int i = 0; i < DVD.length; i++) {
			if (DVD[i] == null) {
				return;
			}
			DVD[i].show();
		}
	}

	public boolean deleteDVD(String name1) {
		for (int i = 1; i < DVD.length; i++) {
			if (name1.equals(DVD[i].name)) {
				DVD[i] = null;
			}
			for (int j = i; j < DVD.length - 1; j++) {
				DVD[i] = DVD[i + 1];
			}
			if (DVD[DVD.length - 1] != null)
				DVD[DVD.length - 1] = null;
			break;
		}
		return true;
	}

	public Dvd lendDVD(String name2) {
		for (int i = 0; i < DVD.length; i++) {
			if (name2.equals(DVD[i].name)) {
				return DVD[i];
			}
		}
		return null;
	}

	public Dvd returnDVD(String name3) {
		for (int i = 0; i < DVD.length; i++) {
			if (name3.equals(DVD[i].name)) {
				return DVD[i];
			}
		}
		return null;

	}

}
